package by.bsu.scs_bsu.custom_tags;

import java.util.ArrayList;
import java.util.HashMap;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import org.apache.log4j.Logger;

public class ScreenTag extends SimpleTagSupport {
	
	private static final Logger LOGGER = Logger.getLogger("system_logger");
	
	private ArrayList <Parameter> parameters = null;
	private String screenId;
	
	public ArrayList getParamaters() {
		return parameters;
	}
	
	public void setScreenId(String screenId) {
        this.screenId = screenId;
    }
	
	public void doTag() {
		parameters = new ArrayList<Parameter>();
		HashMap screens = ((DefinitionTag) getParent()).getScreens();
		if(screens != null) {
			try {
				if(!screens.containsKey(screenId)) {
					screens.put(screenId, parameters);
				}
				getJspBody().invoke(null);
			} catch (Exception e) {
				LOGGER.debug("ScreenTag:" + e.toString());
			}
		}
		else {
			LOGGER.debug("ScreenTag: Unable to get screens object.");
		}
		
		
	}
}
